package com.he.heblog.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.he.heblog.entity.Tag;
import com.he.heblog.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/articleType")
public class ArticleTypeController {
    @Autowired
    TagService tagService;

    //    传一个文章类型ID，返回文章标签集合
    @ResponseBody
    @GetMapping("/tagList/{id}")
    public List<Tag> getTagListByArticleTypeList(@PathVariable Integer id){
        //根据文章类型ID查询文章标签集合
        LambdaQueryWrapper<Tag> tagLambdaQueryWrapper = new LambdaQueryWrapper<>();
        tagLambdaQueryWrapper.eq(Tag::getTypeID,id);
        List<Tag> list = tagService.list(tagLambdaQueryWrapper);
       return list;
    }






}
